<template>
	<view>
		<view class="CountDown"> 获取验证码</view>
		<u-button type="error" @click="getCode" style="width: 50%;" :disabled='btn_show'>{{content_code}}</u-button>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				content_code: '获取验证码',
				time:60,
				btn_show:false
			}
		},
		methods: {
			getCode() {
				this.btn_show=true
				this.content_code=`重新获取：${this.time}秒`
				let timer = null
				timer=setInterval(()=>{
					// console.log('00')
					this.time--
					this.content_code=`重新获取：${this.time}秒`
					if(this.time==0){
						this.btn_show=false
						this.content_code='获取验证码'
						clearInterval(timer)
						this.time=60
					}
				},1000)
			}
			

		}
	}
</script>

<style>
	.CountDown {
		text-align: center;
		margin-top: 400rpx;
		margin-bottom: 20rpx;
		font-size: 48rpx;
		font-weight: 600rpx;
	}
</style>
